<?xml version="1.0"?>

<st-source>
<time-stamp>From VisualWorks® NonCommercial, 7.6 of March 3, 2008 on April 7, 2009 at 3:52:59 pm</time-stamp>


<class>
<name>Supplier</name>
<environment>SupplyChain</environment>
<super>Core.Object</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>inventory lots name location number </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<methods>
<class-id>SupplyChain.Supplier class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<comment>
<class-id>SupplyChain.Supplier</class-id>
<body>A Supplier.

Instance Variables:
	inventory	&lt;Inventory&gt;	Inventory if the supplier
	lots	&lt;Collection&gt;	collection of lots that make up the inventory

</body>
</comment>

<methods>
<class-id>SupplyChain.Supplier</class-id> <category>accessing</category>

<body package="SupplyChain" selector="inventory">inventory
	
	^inventory</body>

<body package="SupplyChain" selector="inventory:">inventory: anInventory
	
	inventory := anInventory.
	^self</body>

<body package="SupplyChain" selector="location">location
	^location.</body>

<body package="SupplyChain" selector="location:">location: anObject
	location := anObject.</body>

<body package="SupplyChain" selector="lots">lots

	^lots.
</body>

<body package="SupplyChain" selector="lots:">lots: aLot
	
	lots:= aLot.
	^self</body>

<body package="SupplyChain" selector="name">name

	^name</body>

<body package="SupplyChain" selector="name:">name: aName
	
	name:= aName.
	^self</body>

<body package="SupplyChain" selector="number">number

	^number</body>

<body package="SupplyChain" selector="number:">number: aNumber
	
	number:= aNumber.
	^self</body>
</methods>

<methods>
<class-id>SupplyChain.Supplier</class-id> <category>selling-ordering</category>

<body package="SupplyChain" selector="createLot:">createLot: newLot

	lots add: newLot.

	^self</body>

<body package="SupplyChain" selector="orderItems:">orderItems: items
	"takes in an Ordered Collection of items, makes an invoice for those items, updates with the newest information based on the Supplier (i.e. buyPrice, sellPrice, lotNumber, etc...), and returns the invoice containing the requested Items. "

	| invoice item updatedList temp |

	updatedList := OrderedCollection new.
	invoice:= Invoice new.
	

	items do:[:i | 
		item:= inventory items detect: [:a | a name = i name ].
		temp := item quantity.
		item quantity: i quantity.
		updatedList add: item.
		inventory items remove: item.
		item quantity: (temp - i quantity).
		inventory items add: item.
	].
	
	invoice itemList: updatedList.
	^invoice</body>

<body package="SupplyChain" selector="sellItem:">sellItem: anItem
	"takes in an Item and returns a Boolean if the supplier sells that type of Item. (i.e. it is in its inventory)"
	
	^inventory items includes: anItem</body>
</methods>

<methods>
<class-id>SupplyChain.Supplier</class-id> <category>printing</category>

<body package="SupplyChain" selector="printString">printString
	^(name,' ', location, ' ', number).</body>
</methods>

<methods>
<class-id>SupplyChain.Supplier</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	lots := OrderedCollection new.
	inventory:= Inventory new.
	"inventory sortBlock:[:a :b | a lotNumber &lt; b lotNumber]."
	name:= 'Default'.
	location := 'Place'.
	number := nil.

	^self</body>
</methods>

</st-source>
